#include<bits/stdc++.h>
using namespace std;
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int n, m;
__int128 line[110];
__int128 c[110];
__int128 F[100][100];
__int128 ans;

void init()
{
	c[0] = 1;
	for (int i = 1; i <= 80; i++) 
		c[i] = c[i-1] * 2;
	return ;
}

void print(__int128 x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
	return ;
}

int main()
{
	read(n);read(m);

	init();
	for (int i = 1; i <= n; i++) 
	{
		for (int j = 1; j <= m; j++) 
			read(line[j]);

		memset(F, 0, sizeof(F));
		for (int len = m-1; len >= 1; len--) 
		{
			for (int l = 1; l <= m - len + 1; l++) 
			{
				int r = l + len - 1;
				F[l][r] = max(F[l][r], F[l-1][r] + line[l-1] * c[m-len] );
				F[l][r] = max(F[l][r], F[l][r+1] + line[r+1] * c[m-len] );
			}
		}
		
		__int128 mx = 0;
		for (int j = 1; j <= m; j++) 
			mx = max(mx, F[j][j] + (1 << m) * line[j]);

		ans += mx;
	}

	print(ans);

	return 0;
}
